﻿var asteroid = function(size, life, angle, rotation, x, y, vx, vy) {
	this.size = size;
	this.life = life;
	this.angle = angle;
	this.rotation = rotation;
	this.x = x;
	this.y = y;
	this.vx = vx;
	this.vy = vy;
};

var explosion = function(x, y, size, img) {
	this.x = x;
	this.y = y;
	this.size = size;
	this.frame = 15;
	this.img = img || explosionImg;
};

var infoText = function(x, y, time, text, color) {
	this.x = x;
	this.y = y;
	this.time = time;
	this.total = time;
	this.text = text;
	this.color = color;
}

var particle = function(x, y, vx, vy, owner) {
	this.x = x;
	this.y = y;
	this.vx = vx;
	this.vy = vy;
	this.owner = owner;
	this.lifetime = MAX_PARTICLE_TIME;
};

var keyboard = {
	shoot : false,
	left : false,
	right: false,
	up : false,
	down : false,
	press : function(e) {
		manageKeyboard(e.keyCode, true);
	},
	release : function(e) {
		manageKeyboard(e.keyCode, false);
	}
};

var ship = function(id, control, color) {
	this.id = id || 1;					//Sets the ID of the SHIP (1 is always the own ship)
	this.control = control || keyboard;	//Sets the control of the SHIP (keyboard is local control)
	this.x = c.canvas.width / 2;		//Centeres start X
	this.y = c.canvas.height / 2;		//Centeres start Y
	this.angle = 0;						//Sets start angle to 0
	this.ammo = MAX_AMMO;				//Sets start ammo to maximum
	this.cooldown = 0;					//Sets start cooldown to minimum
	this.color = (color || 0) % primaryColors.length;//Sets the ship's color
	this.life = MAX_LIFE;				//Sets start life to maximum
	this.boost = 0;						//Sets start boost to minimum
	this.hitByAsteroid = 0;				//Final statistic - how often hit by asteroid?
	this.hitAsteroids = 0;				//Final statistic - how often did kill an asteroid?
	this.shotAsteroids = 0;				//Final statistic - how often did hit an asteroid?
	this.hitShips = 0;					//Final statistic - hofen did hit another ship?
};